<template>
	<view class="t-table">
		<slot />
	</view>
</template>

<script>
	export default {
		props: {
			isCheck: {
				type: Boolean,
				default: false
			}
		},
		provide() {
			return {
				table: this
			};
		},
		data() {
			return {};
		},
		created() {
			this.childrens = [];
			this.index = 0;
		},
		methods: {
			fire(e, index, len) {
				let childrens = this.childrens;
				console.log(childrens);
				// 全选
				if (index === 0) {
					childrens.map((vm, index) => {
						vm.checkboxData.checked = e;
						return vm;
					});
				} else {
					let isAll = childrens.find((n, ids) => ids !== 0 && !n.checkboxData.checked);
					childrens[0].checkboxData.checked = isAll ? false : true;
				}

				let fireArr = [];
				for (let i = 0; i < childrens.length; i++) {
					if (childrens[i].checkboxData.checked && i !== 0) {
						fireArr.push(childrens[i].checkboxData.value - 1);
					}
				}
				this.$emit('change', {
					detail: fireArr
				});
			}
		}
	};
</script>

<style scoped>
	.t-table {
		width: 100%;
		box-sizing: border-box;
		border: 1rpx solid #F6F7FB;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		overflow: hidden;
		-webkit-backface-visibility: hidden;
		-webkit-transform: translate3d(0, 0, 0);
	}

	.t-table>>>t-tr {
		display: flex;
		align-items: center;
		min-height: 80rpx;
		border-bottom: 1rpx solid #F6F7FB;
	}
	
	
	.t-table>>>t-tr:first-child {
		background: #F6F7FB;
		color: #9095AD;
		min-height: 60rpx;
		/* line-height: 60rpx; */
		border-bottom: none;
	}
	

	.t-table>>>t-tr:last-child {
		border-bottom: none;
	}
	
	.t-table>>>t-td {
		/* display: flex;
		align-items: center;
		justify-content: center;
		padding:20rpx 0; */
	}


	/* .t-table>>>t-tr:nth-child(2n) {
		background: #f5f5f5;
	} */

	/* #ifdef H5 */
	/* .t-table>>>.t-tr:nth-child(2n) {
		background: #f5f5f5;
	} */
	/* #endif */
</style>
